package com.es.test.service.query;

import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import co.elastic.clients.elasticsearch._types.query_dsl.RangeQuery;
import co.elastic.clients.json.JsonData;
import com.es.test.query.Field;

public class RangeLteQueryBuilder implements QueryBuilder{
    @Override
    public Query build(Field field) {
        Query query = RangeQuery.of(r -> r
                .field(field.getFieldName())
                .lte(JsonData.of(Double.parseDouble(String.valueOf(field.getFiledValue())))
                )
        )._toQuery();
        return query;
    }
}
